home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 37 / CD Expert nº 37.iso / LastCall / lastcall.exe / stuff / lastcall.dxr / 00208_Game Done, etc..ls < prev    next >
Encoding:
Text File  |  2000-03-27  |  10.7 KB  |  438 lines

  1. global gPlayerName, gGameLevel, gPlayerTips, gHighScores, gMaxHiScores, gGameSetup, gGameLevelStartTime, gPlayerTipsThisLevel, gGameLevelTime, gDrinksServedThisLevel, gDemoVersion
  2.  
  3. on continueGame
  4.   global gGameLevelStartTime, gPauseState
  5.   if inBonusMode() then
  6.     if gDemoVersion then
  7.       go("Main Menu")
  8.       exit
  9.     end if
  10.     gPauseState = 0
  11.     startBonusMode()
  12.     if inShotMode() then
  13.       returnToBar(#shot)
  14.     else
  15.       gotoBonusRound()
  16.     end if
  17.     exit
  18.   end if
  19.   resetForcedCharacterTimer()
  20.   if inGameMode() then
  21.     startNextLEvel()
  22.     if gDemoVersion and (gGameLevel > 1) then
  23.       go("Main Menu")
  24.       exit
  25.     end if
  26.     gGameLevelStartTime = elapsedTime(gGameLevelTime)
  27.     returnToBar(#game)
  28.     newCharacterEnters(#Always)
  29.   else
  30.     if gDemoVersion then
  31.       go("Main Menu")
  32.       exit
  33.     end if
  34.     gGameLevel = 0
  35.     startNewGame()
  36.     startNextLEvel()
  37.     gGameLevelStartTime = now()
  38.     returnToBar(#recipe)
  39.     newCharacterEnters(#Always, VOID, 2)
  40.   end if
  41.   restoreWindowState()
  42.   pullWindowsForward()
  43. end
  44.  
  45. on restartGameLevel
  46.   global gBounceInProgress, gNewLevel, gPauseState, gPauseTime, gGameLevelTime, gGameLevelStartTime
  47.   gPauseTime = 0
  48.   gPauseState = 0
  49.   reinitializeCharacters()
  50.   reinitializeBarTopManager()
  51.   waitCursor()
  52.   readInData()
  53.   refreshTipRegister()
  54.   gGameLevelStartTime = elapsedTime(gGameLevelTime)
  55.   gNewLevel = 0
  56.   playTrack()
  57.   resetCursor()
  58. end
  59.  
  60. on restartBonusRound
  61.   global gPauseState, gPauseTime, gBonusLimit, gBonusStartTime, gGameLevelTime
  62.   gPauseTime = 0
  63.   gPauseState = 0
  64.   gBonusStartTime = elapsedTime(gGameLevelTime)
  65.   playTrack()
  66.   refreshTipRegister(VOID, 1)
  67.   waitCursor()
  68.   readInData()
  69.   resetCursor()
  70. end
  71.  
  72. on startNextLEvel
  73.   global gBounceInProgress, gNewLevel, gServedUnderage, gPauseState, gPauseTime, gRecipeWindowOpenTime, gTotalAccuracy, gPlayerCardWarnings, gWarnedAboutGlassesUnderBar, gPearlyGates, gUserQuitFlag, gCharChildren
  74.   gPearlyGates = 0
  75.   gUserQuitFlag = 0
  76.   gWarnedAboutGlassesUnderBar = 0
  77.   gPlayerCardWarnings = 0
  78.   gServedUnderage = 0
  79.   gRecipeWindowOpenTime = 0
  80.   gTotalAccuracy = 0
  81.   gPauseTime = 0
  82.   gPauseState = 0
  83.   gNewLevel = 1
  84.   gGameLevel = gGameLevel + 1
  85.   if gGameLevel > 1 then
  86.     setLevelCurrentSong()
  87.   end if
  88.   reinitializeBarTopManager()
  89.   repeat with persistentPatron in gCharChildren
  90.     mSoberUp(persistentPatron)
  91.   end repeat
  92.   repeat with X = 9 to 20
  93.     sendSprite(X, #beginSprite)
  94.   end repeat
  95.   emptyGlasses(1)
  96.   repeat with X = 78 to 89
  97.     sendSprite(X, #beginSprite)
  98.     sendSprite(X, #mRemoveDrink)
  99.   end repeat
  100.   gBounceInProgress = 0
  101.   gPlayerTipsThisLevel = 0
  102.   refreshTipRegister()
  103.   gDrinksServedThisLevel = 0
  104.   gGameLevelTime = 0
  105.   if gGameLevel > count(gGameSetup) then
  106.     endOfGame()
  107.     abort()
  108.   end if
  109. end
  110.  
  111. on beyondMaxTips
  112.   global gPlayerTipsThisLevel
  113.   if (gPlayerTipsThisLevel >= currentLevel(#MAXEARLYTIPS)) and inGameMode() then
  114.     return 1
  115.   else
  116.     return 0
  117.   end if
  118. end
  119.  
  120. on beyondMinTips factor
  121.   global gPlayerTipsThisLevel
  122.   if voidp(factor) then
  123.     factor = 1.0
  124.   end if
  125.   if (gPlayerTipsThisLevel >= (currentLevel(#MINTIPS) * factor)) and inGameMode() then
  126.     return 1
  127.   else
  128.     return 0
  129.   end if
  130. end
  131.  
  132. on endOfLevel
  133.   global gGameLevelStartTime, gLeftOverTime, gServedUnderage, gUserQuitFlag
  134.   gLeftOverTime = max(0, timeLeftOnThisLevel())
  135.   waitForDraggingMIAW()
  136.   beginPause()
  137.   dismissAllCrap(inMixingMode())
  138.   menuMode(1)
  139.   updateStage()
  140.   if inBonusMode() then
  141.     go("BonusSummary")
  142.   else
  143.     if inPracticeMode() or gServedUnderage or gUserQuitFlag then
  144.       gotoRoundSummary()
  145.     else
  146.       if beyondMaxTips() then
  147.         gotoRoundSummary()
  148.         managerVO("U01", 1)
  149.       else
  150.         if beyondMinTips(1.5) then
  151.           gotoRoundSummary()
  152.           managerVO(randomFromList(["O01", "W02", "W03", "x03"]), 0)
  153.         else
  154.           if beyondMinTips() then
  155.             gotoRoundSummary()
  156.             managerVO("O02", 0)
  157.           else
  158.             gotoRoundSummary()
  159.             managerVO("E05", 1)
  160.             if gPlayerTipsThisLevel < (currentLevel(#MINTIPS) / 3) then
  161.               managerVO("U03", 1)
  162.               if gGameLevel = 1 then
  163.                 managerVO(randomFromList(["u07", "U10", "u14"]), 0)
  164.               end if
  165.             else
  166.               managerVO(randomFromList(["U02"]), 0)
  167.             end if
  168.           end if
  169.         end if
  170.       end if
  171.     end if
  172.   end if
  173.   gGameLevelStartTime = now()
  174. end
  175.  
  176. on endOfGame
  177.   global gUserQuitFlag, gLastSavedGameName
  178.   beginPause()
  179.   setLevelCurrentSong()
  180.   if (gUserQuitFlag = 0) or (gLastSavedGameName = EMPTY) then
  181.     eligible = 1
  182.   else
  183.     eligible = 0
  184.   end if
  185.   if inPracticeMode() or not eligible then
  186.     exitGame(0)
  187.     exit
  188.   end if
  189.   if gPlayerTips > 0 then
  190.     newHi = checkHiScore(1)
  191.   else
  192.     newHi = 0
  193.   end if
  194.   if newHi > 0 then
  195.     updateHighScoreChart()
  196.     dismissAllCrap(0)
  197.     if heavenly(newHi) then
  198.       showHeaven()
  199.     else
  200.       go("High Scores")
  201.     end if
  202.   else
  203.     exitGame(0)
  204.   end if
  205. end
  206.  
  207. on heavenly newHi
  208.   global gGameLevel, gGameSetup, gEasyHeaven, gPlayerTips, gMaxTips
  209.   if (gGameLevel >= 5) and (newHi = 1) then
  210.     return 1
  211.   else
  212.     if gEasyHeaven and (gGameLevel >= 1) then
  213.       return 1
  214.     else
  215.       if gGameLevel > count(gGameSetup) then
  216.         return 1
  217.       else
  218.         if gPlayerTips >= gMaxTips then
  219.           return 1
  220.         else
  221.           return 0
  222.         end if
  223.       end if
  224.     end if
  225.   end if
  226. end
  227.  
  228. on showHeaven
  229.   global gPearlyGates
  230.   gPearlyGates = 1
  231.   closeDownTheShow()
  232. end
  233.  
  234. on closeDownTheShow
  235.   closeAllWindows(0)
  236.   replaceDraggingAnything()
  237.   go("WaitForPatrons")
  238.   abort()
  239. end
  240.  
  241. on hideDragRect
  242.   global gDragRect, gActiveWindow
  243.   gActiveWindow = the stage
  244.   sprite(gDragRect).rect = rect(-10, -10, -5, -5)
  245. end
  246.  
  247. on dismissAllCrap saveWindows
  248.   stopPatronSounds()
  249.   closeAllWindows(saveWindows)
  250.   replaceDraggingAnything()
  251.   the actorList = []
  252.   dismissToolTip(1)
  253.   hideDragRect()
  254. end
  255.  
  256. on storeLastIngredient ingredient
  257.   global gLastIngredient, gRecoverLastIngredient
  258.   gLastIngredient = ingredient
  259.   if not isGlassNotBeer(ingredient) and not isVessel(ingredient) then
  260.     gRecoverLastIngredient = ingredient
  261.   end if
  262. end
  263.  
  264. on replaceDraggingAnything
  265.   global gXbottlePopup, gSodaGunPopup, gMatrixMode
  266.   gMatrixMode = 0
  267.   stopSoundFX()
  268.   replaceActiveBottle()
  269.   replaceWellItem()
  270.   sendSprite(gXbottlePopup, #mHidePopup)
  271.   sendSprite(gSodaGunPopup, #mHidePopup)
  272. end
  273.  
  274. on quitSequence
  275.   global gGameLevel
  276.   if gGameLevel = 0 then
  277.     quitTheProjector()
  278.   else
  279.     quitGame()
  280.   end if
  281. end
  282.  
  283. on quitTheProjector
  284.   answer = yesNoDialogBox("Are you sure you want to exit?", "Exit?", #question, #NO)
  285.   if answer = #yes then
  286.     go("Quit")
  287.   end if
  288. end
  289.  
  290. on exitGame saveWindows
  291.   dismissAllCrap(saveWindows)
  292.   go("Main Menu")
  293. end
  294.  
  295. on removeGarnish
  296.   global gBarTopManager
  297.   barGlass = getActiveGlass()
  298.   if barGlass <> 0 then
  299.     barSlot = glassSpriteToBarSlot(barGlass.spriteNum)
  300.     status = sprite(barSlotToSprite(barSlot)).pStatus
  301.     if getOne([#serving, #served], status) then
  302.       alertBeep()
  303.       exit
  304.     end if
  305.     glassType = getBarTopGlass(gBarTopManager, barSlot)
  306.     if glassType = #none then
  307.       exit
  308.     end if
  309.     ungarnishedGlass = glassPrefix(glassType) & "_none"
  310.     setBarTopGlass(gBarTopManager, barSlot, member(ungarnishedGlass), glassType, 1, VOID, #noGarnish)
  311.     clickSound()
  312.   end if
  313. end
  314.  
  315. on emptyGlasses silent, mixingGlassesOnly, activeGlassOnly
  316.   global gMixingVesselsList, gWastingLiquorWarnings
  317.   admonish = 0
  318.   thisGlass = getActiveGlass()
  319.   thisPatron = getActiveCharacter()
  320.   if thisPatron = 0 then
  321.     exit
  322.   end if
  323.   if not mixingGlassesOnly and (thisGlass <> 0) then
  324.     if sprite(thisPatron).pStatus = #serving then
  325.       alertBeep()
  326.       exit
  327.     end if
  328.     if sendSprite(thisGlass, #mIsHoldingLiquor) > 0 then
  329.       admonish = 1
  330.     end if
  331.     sendSprite(thisGlass, #mEmptyGlass)
  332.     sendSprite(thisGlass, #mDropIt)
  333.   end if
  334.   if not activeGlassOnly then
  335.     repeat with X in gMixingVesselsList
  336.       if sendSprite(X, #mIsHoldingLiquor) > 0 then
  337.         admonish = 1
  338.       end if
  339.       sendSprite(X, #mEmptyGlass)
  340.     end repeat
  341.   end if
  342.   if admonish and not silent then
  343.     gWastingLiquorWarnings = gWastingLiquorWarnings + 1
  344.     if gWastingLiquorWarnings = 1 then
  345.       managerVO("R01")
  346.     else
  347.       if gWastingLiquorWarnings = 3 then
  348.         gWastingLiquorWarnings = 0
  349.       end if
  350.     end if
  351.   end if
  352.   resetPourMeter()
  353. end
  354.  
  355. on checkHiScore recordIt, newScore
  356.   global gPlayerTips
  357.   if voidp(newScore) then
  358.     newScore = gPlayerTips
  359.   end if
  360.   if newScore = 0 then
  361.     return 0
  362.   end if
  363.   repeat with X = 1 to count(gHighScores)
  364.     if newScore > gHighScores[X][#tips] then
  365.       exit repeat
  366.     end if
  367.   end repeat
  368.   if X <= gMaxHiScores then
  369.     if recordIt then
  370.       gHighScores[X] = [#playerName: gPlayerName, #level: gGameLevel, #tips: newScore]
  371.       if count(gHighScores) > gMaxHiScores then
  372.         deleteAt(gHighScores, gMaxHiScores + 1)
  373.       end if
  374.     end if
  375.     return X
  376.   else
  377.     return 0
  378.   end if
  379. end
  380.  
  381. on formatHiScoreData addDollarSign
  382.   if addDollarSign then
  383.     dollarSign = "$ "
  384.     tempText = EMPTY
  385.   else
  386.     tempText = fileVersion(#hiscore) & RETURN
  387.     dollarSign = EMPTY
  388.   end if
  389.   repeat with X = 1 to min(gMaxHiScores, count(gHighScores))
  390.     put gHighScores[X][#playerName] & TAB & gHighScores[X][#level] & TAB & dollarSign & float(gHighScores[X][#tips]) & RETURN after dollarSign
  391.   end repeat
  392.   delete char -30000 of tempText
  393.   return tempText
  394. end
  395.  
  396. on updateHighScoreChart
  397.   global gHighScoreFile
  398.   hiScoreData = formatHiScoreData(0)
  399.   success = saveGame(gHighScoreFile, hiScoreData, "Hi Score Data", "HiScores.RYE", "LChs BEER")
  400. end
  401.  
  402. on retrieveHiScores
  403.   global gHighScoreFile, gInText
  404.   gHighScores = []
  405.   hiScoreData = retrieveFile(gHighScoreFile)
  406.   if not voidp(hiScoreData) then
  407.     gInText = hiScoreData
  408.     if checkVersionString(#hiscore) then
  409.       parseHiScoreData(gInText)
  410.     end if
  411.   end if
  412. end
  413.  
  414. on parseHiScoreData userData
  415.   oldDelimiter = the itemDelimiter
  416.   the itemDelimiter = TAB
  417.   gHighScores = []
  418.   numLines = the number of lines in userData
  419.   repeat with X = 1 to min(gMaxHiScores, numLines)
  420.     thisLine = userData.line[X]
  421.     name = thisLine.item[1]
  422.     level = integer(thisLine.item[2])
  423.     tips = value(thisLine.item[3])
  424.     gHighScores[X] = [#playerName: name, #level: level, #tips: tips]
  425.   end repeat
  426.   the itemDelimiter = oldDelimiter
  427. end
  428.  
  429. on formatObjectives thisLevel
  430.   global gGameSetup
  431.   thisRound = gGameSetup[thisLevel]
  432.   temp = "Get ready to mix some drinks! Earn at least the minimum tips in the allotted time to advance to the bonus round. Earn tips faster to advance early." & RETURN & RETURN
  433.   temp = temp & "Maximum Time this shift:" & TAB & integer(ticksToMinutes(thisRound[#duration])) && "minutes" & RETURN
  434.   temp = temp & "Minimum Tips to advance:" & TAB & "$" & float(thisRound[#MINTIPS]) & RETURN
  435.   temp = temp & "Advance early if you earn:" & TAB & "$" & float(thisRound[#MAXEARLYTIPS])
  436.   return temp
  437. end
  438.